package com.duartepeixinho.P3D.Core.Math 
{
	/**
	 * P3D
	 * @version 0.1
	 * @author Duarte Peixinho
	 */
	public class Vector4
	{
		
		private var _x:Number;
		private var _y:Number;
		private var _z:Number;
		private var _w:Number;
		
		public function Vector4(x:Number=0, y:Number=0, z:Number=0, w:Number = 0) {
			
			_x = x;
			_y = y;
			_z = z;
			_w = w;
			
		}
		
		// Getters & Setters
		
		public function get x():Number {
			return _x;
		}
		public function get y():Number {
			return _y;
		}
		public function set x(x:Number):void {
			_x = x;
		}
		public function set y(y:Number):void {
			_y = y;
		}		
		public function get z():Number {
			return _z;
		}
		public function set z(z:Number):void {
			_z = z;
		}
		public function get w():Number {
			return _w;
		}
		public function set w(w:Number):void {
			_w = w;
		}
		
		// Vector Calculations
		
		/**
		 * Add Vector
		 * @param	vector	Vector4	Vector to Add
		 * @return			Vector4	Returns changed vector
		 */
		public function addVector(vector:Vector4):Vector4 {
			return new Vector4(_x + vector.x, _y + vector.y, _z + vector.z);
		}
		
		/**
		 * Subtract Vector
		 * @param	vector	Vector4	Vector to Subtract
		 * @return			Vector4	Returns changed vector
		 */
		public function subVector(vector:Vector4):Vector4 {
			return new Vector4(_x - vector.x, _y - vector.y, _z - vector.z);
		}
		
		/**
		 * Copy Vector
		 * @param	vector	Vector4	Vector to copy
		 */
		public function copy(vector:Vector4):void {
			_x = vector.x;
			_y = vector.y;
			_z = vector.z;
		}
		
		/**
		 * Clone Vector
		 * @return			Vector4	Returns a new Vector
		 */
		public function clone():Vector4 {
			return new Vector4(_x, _y, _z);
		}		
		
		/**
		 * toString
		 * @return			String	Returns vector in a String
		 */
		public function toString():String {
			return "Vector4(" + _x.toString() + "," + _y.toString() + "," + _z.toString() + "," + _w.toString() + ")";
		}
		
	}

}